#include"process.h"
#include<string.h>
#include<unistd.h>

#define NUM 101
#define STYLE '#'

void process_v1()
{
	char proc[NUM];
	memset(proc, 0, sizeof(proc));
	int i = 0;
	for(i = 0;i < 101;i++)
	{
		printf("[%-100s][%d%%]\r", proc, i);
		fflush(stdout);
		proc[i] = '#';
		usleep(50000);
	}
	printf("\n");
}

void FlushProcess(double total, double current)
{
	char proc[NUM];
	memset(proc, 0, sizeof(proc));
	const char* lable = "|/-\\";
	static int cnt = 0;

	int num = (int)(current*100/total);
	int i = 0;	
	for(i = 0;i < num;i++)
	{
		proc[i] = '#';
	}
	double rate = current/total;
	cnt %= 4;
	printf("[%-100s][%.1f%%][%c]\r", proc, rate*100, lable[cnt]);
	cnt++;
	fflush(stdout);
}
